'use strict';
/**
 * Created by FreezeSoul on 2015/10/16.
 */
define([
        'angular',
        'app/core/loader',
        'app/modules/index/define'
    ],
    function(angular,plugin) {
        angular.module('ad.index')
            .directive('indexTypeToName', ['_',function(_) {
                    return {
                        template: '<span>{{TypeName}}</span>',
                        scope: {
                            typeId: '='
                        },
                        link: function($scope, $elm, $attrs, $ctrl) {
                            plugin.initManifests().then(function() {
                                var manifests = arguments;
                                var item = _.find(manifests,function(manifest){
                                    return manifest.uid == $scope.typeId;
                                });
                                if(item)
                                    $scope.TypeName = item.name;
                                else
                                    $scope.TypeName = $scope.typeId;
                                $scope.$digest();
                            });

                        }
                    };
                }
            ]);
    });